<template>
  <el-tabs v-model="activeName" @tab-click="tab" class="secondNav">
    <el-tab-pane :label="item.label" :name="item.name" v-for="item in tabs">
    </el-tab-pane>
    <keep-alive>
      <component :is="activeName" class="content"></component>
    </keep-alive>
  </el-tabs>
</template>
<script>
  import questionnaireInfo from './quesConfig/index.vue'
  import questionnaireImport from './quesImport/index.vue'
  import {isHasMenu} from '@/utils/m7Utils'
  export default {
    name: 'questionnaireConfig',
    data () {
      return {
        activeName: 'questionnaireInfo',
        currentRoute: '',
        tabs: [
          {name: 'questionnaireInfo', label: this.$t('configLazyLoad.questionnaireConfig.questionnaireConfig'), id: 'questionnaire_config'},
          {name: 'questionnaireImport', label: this.$t('configLazyLoad.questionnaireConfig.questionnaireImport'), id: 'questionnaire_impport'}
        ]
      }
    },
    components: {
      questionnaireInfo,
      questionnaireImport
    },
    methods: {
      tab (tab, event) {
      }
    },
//    beforeRouteLeave (to, from, next) {
//      this.currentRoute = from.fullPath
//      next()
//    },
//    beforeRouteEnter (to, from, next) {
//      next(vm => {
//        if (vm.currentRoute) {
//          vm.$router.push({path: vm.currentRoute})
//        }
//      })
//    },
    beforeMount () {
      this.tabs = this.tabs.filter((item) => {
        if (isHasMenu(item.id, this.$store.state.session.user)) {
          return true
        }
      })
      this.activeName = this.tabs[0].name
    }
  }
</script>
<style lang="stylus" scoped>
  @import "../../../../assets/common.styl"
</style>
